//
//  ChengJiaoZhungTaiHuiTuiViewController.m
//  JuBoCRM
//
//  Created by iMac on 2024/10/21.
//  Copyright © 2024 iningKe. All rights reserved.
//

#import "ChengJiaoZhungTaiHuiTuiViewController.h"
#import "BRStringPickerView.h"
@interface ChengJiaoZhungTaiHuiTuiViewController ()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topSpace;
@property (weak, nonatomic) IBOutlet TPKeyboardAvoidingScrollView *mainScrollView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomSpace;

@property (weak, nonatomic) IBOutlet UITextField *chengJiaoTf;
@property (weak, nonatomic) IBOutlet UITextField *fuKuanFangShiTf;

@end

@implementation ChengJiaoZhungTaiHuiTuiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.customNavBar.title = @"客户成交状态";
    if (@available(iOS 11.0, *)) {
        self.mainScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    _topSpace.constant = NavaBarHeight;
    _bottomSpace.constant = 20+ScreenBottom;
}
//付款方式
- (IBAction)fuKuanFangShi:(UIButton *)sender {
    BRStringPickerView *datePickerView = [[BRStringPickerView alloc]init];
    datePickerView.pickerMode = BRStringPickerComponentSingle;
    datePickerView.title = @"";
    datePickerView.dataSourceArr = @[@"已退款",@"未退款"];
    datePickerView.selectValue = _fuKuanFangShiTf.text;
    //    strPickerView.isAutoSelect = isAutoSelect;
    datePickerView.resultModelBlock = ^(BRResultModel *resultModel) {
        NSLog(@"选择的索引：%@", @(resultModel.index));
        NSLog(@"选择的值：%@", resultModel.value);
        
        _fuKuanFangShiTf.text = resultModel.value;
        
    };
    
    BRPickerStyle *customStyle = [[BRPickerStyle alloc]init];
    customStyle.pickerColor = [UIColor whiteColor];
    customStyle.selectRowTextColor = rgba(40, 120, 255, 1);
    customStyle.titleBarColor = [UIColor whiteColor];
    customStyle.titleTextColor = [UIColor whiteColor];
    customStyle.cancelTextColor = rgba(153, 153, 153, 1);
    customStyle.doneTextColor = rgba(40, 120, 255, 1);
    customStyle.titleBarHeight = 48;
    customStyle.titleTextFont = [UIFont systemFontOfSize:18];
    datePickerView.pickerStyle = customStyle;
    customStyle.topCornerRadius = 10;
    customStyle.hiddenTitleLine = YES;
    customStyle.separatorColor = rgba(223, 229, 242, 1);
    customStyle.separatorHeight = 0.5;
    customStyle.rowHeight = 64;
    
    [datePickerView show];
}
//取消
- (IBAction)quXiao:(id)sender {
    [self.view endEditing:YES];
    [self.navigationController popViewControllerAnimated:YES];
}
//确定
- (IBAction)queDing:(UIButton *)sender {
    [self.view endEditing:YES];
    
    if(_fuKuanFangShiTf.text.length == 0){
        [ZZPUtils showWarning:_fuKuanFangShiTf.placeholder];
        return;
    }
    
    NSMutableDictionary *paraDic = [NSMutableDictionary dictionary];
    [paraDic setValue:@"0" forKey:@"dealStatus"];
    if ([_fuKuanFangShiTf.text isEqualToString:@"已退款"]) {
        [paraDic setValue:@"1" forKey:@"isRefund"];
    }else{
        [paraDic setValue:@"0" forKey:@"isRefund"];
    }
    [paraDic setValue:_ids forKey:@"ids"];
    [[ZZPRequest getWebUtil] postJsonNetworkRequestURLString:@"/crmCustomer/setDealStatus" andParas:paraDic andShowHud:YES andTransferGottenData:^(id info, NSError *error) {
        if (!error) {
            [ZZPUtils showWarning:@"已取消成交"];
            if (_manageClickBlock) {
                _manageClickBlock(0);
            }
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
